package cn.tannn.surenessdemo.user.entity;

import lombok.*;
import org.hibernate.Hibernate;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Index;
import javax.persistence.Table;
import java.util.Objects;

/**
 * 路由资源表（路由跟资源的关系表
 * @date  2021-06-08 09:45:21
 * @author tn
 * @version 1
 */
@Entity
@Table (name ="auth_route_resource_bind", indexes = {
			@Index(name = "route_resource_inde",columnList = "routeCode,resourceCode",unique = true)
		})
@org.hibernate.annotations.Table(appliesTo = "auth_route_resource_bind",comment = "路由资源表（路由跟资源的关系表")
@Getter
@Setter
@ToString
@Builder
@AllArgsConstructor
@NoArgsConstructor
@DynamicUpdate
@DynamicInsert
public class AuthRouteResourceBind extends CommonBean<AuthRouteResourceBind> {


	@Column(columnDefinition="varchar(50) not null COMMENT '路由Code'")
	private String routeCode;

	@Column(columnDefinition="varchar(50) not null  COMMENT '资源Code'")
	private String resourceCode;

	@Override
	public boolean equals(Object o) {
		if (this == o) {
			return true;
		}
		if (o == null || Hibernate.getClass(this) != Hibernate.getClass(o)) {
			return false;
		}
		AuthRouteResourceBind that = (AuthRouteResourceBind) o;
		return getId() != null && Objects.equals(getId(), that.getId());
	}

	@Override
	public int hashCode() {
		return getClass().hashCode();
	}
}
